#include <iostream>
using namespace std;


int main() {
    int year = 0;
    int month = 0;
    int day = 0;
    int sum = 0;

    cin >> year >> month >> day;
    static int arr[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
    
    for (int i = 1; i < month; i++) {
        sum += arr[i];
    }
    sum += day;
    if(month>2 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0))
    {
        sum++;
    }

    cout << sum;
    return 0;
}